
package components;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JComponent;


public class RPSRoundRect extends JComponent {

	private static final long serialVersionUID = 1L;

	
	private Dimension outerDimension;
	private int width;
	private int height;
	private int corner;
	private Color strokeColor;
	private Color fillColor;

	public RPSRoundRect (Dimension outerDimension , int width , int height , int corner , Color strokeColor , Color fillColor) {
		this.outerDimension = outerDimension;
		this.width = width;
		this.height = height;
		this.corner = corner;
		this.strokeColor = strokeColor;
		this.fillColor = fillColor;
		setVisible(true);
	}
	
	private void setMiddle() {
		setBounds((outerDimension.width - width) / 2 , (outerDimension.height - height) / 2 ,width , height);
	}
	public void drawRect (Graphics g) {
		super.paintComponent (g);
		setMiddle();
		Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 
		g2.setColor(fillColor);
		g2.fillRoundRect(0, 0, width,height, corner, corner);
		g2.setColor(strokeColor);
		g2.drawRoundRect(0, 0, width, height, corner, corner);
	}
}	
